package memento;

public class MementoTestMain {
    public static void main(String[] args) {
        TextEditor textEditor = new TextEditor();
        History history = new History();

        textEditor.write("Hello, world!");  // 编辑文本
        history.push(textEditor.save());        // 保存状态

        textEditor.write("This is a backup.");  // 编辑文本
        history.push(textEditor.save());            // 保存状态

        System.out.println("Current content: " + textEditor.getContent());

        // 恢复到之前的状态
        Memento previousState = history.pop();
        if (previousState != null) {
            textEditor.restore(previousState);
        }

        System.out.println("Restored content: " + textEditor.getContent());
    }
}
